package com.jiuyue.movehouse.common.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;

@Getter
public enum OrderState {
    reservation(1,"待接单"),CANCEL(2,"已取消"),GETORDER(3,"已接单"),COMPLETE(4,"待支付"),PAYED(5,"已支付");
    private int id;
    private String name;

    OrderState(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public static List<OrderState> list;

    public static List<OrderState> list()
    {
        if (list != null) {
            return list;
        }

        list = new ArrayList<>();

        EnumSet<OrderState> enumSet = EnumSet.allOf(OrderState.class);
        for (OrderState item : enumSet){
            list.add(item);
        }

        return list;
    }

    public static OrderState getById(int id)
    {
        for (OrderState item :
                list()) {
            if(item.getId()==id){
                return item;
            }
        }
        return null;
    }
}
